"""
7-2 点赞
"""


def resolution1():
    N = int(input())
    mapping = {}
    for _ in range(N):
        lines = list(map(int, input().split(" ")))
        flag = True
        for item in lines:
            # 丢弃第一个无用的数据
            if flag:
                flag = False
                continue
            if mapping.get(item) is not None:
                mapping[item] += 1
            else:
                mapping[item] = 1
    max_count = max(mapping.values())
    rising_ids = sorted(mapping.keys(), reverse=True)
    for id in rising_ids:
        if mapping[id] == max_count:
            print(id, max_count)
            break


if __name__ == '__main__':
    resolution1()